//
//  RewardRulesVC.m
//  WanCaiC8
//
//  Created by tangang on 2018/3/21.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "RewardRulesVC.h"

@interface RewardRulesVC ()

@end

@implementation RewardRulesVC{
    UIScrollView    *scrollView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"奖励规则";
    [self createUI];
    // Do any additional setup after loading the view.
}

- (void)createUI{
    scrollView=[[UIScrollView alloc]initWithFrame:self.view.bounds];
    scrollView.showsVerticalScrollIndicator=NO;
    [self.view addSubview:scrollView];
    QXLable *labTitle=[[QXLable alloc]initWithFount:15];
    labTitle.textColor=NAVCOLOR;
    labTitle.text=@"分享流程";
    labTitle.textAlignment=NSTextAlignmentCenter;
    [scrollView addSubview:labTitle];
    [labTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(scrollView);
        make.centerX.equalTo(scrollView);
        make.size.mas_equalTo(CGSizeMake(100, 38));
    }];
    
    UIImageView *headImageV=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"avatar"]];
    [scrollView addSubview:headImageV];
    [headImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(labTitle.mas_bottom);
        make.centerX.equalTo(labTitle);
        make.size.mas_equalTo(CGSizeMake(real_size(71), real_size(71)));
    }];
    
    UIImageView *bgImage=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"rules_people"]];
    [scrollView addSubview:bgImage];
    [bgImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(headImageV);
        make.top.equalTo(headImageV.mas_bottom).with.offset(-30);
        make.size.mas_equalTo(bgImage.image.size);
    }];
    
    
    NSString *strRules=[NSString stringWithFormat:@"一、活动规则\n1、邀请者邀请好友注册，邀请者可获得1〜100金币奖励，受邀者可获得1〜50金币奖励，同时受邀者注册后充值，邀请者可获得1%%的反馈。\n2、受邀请邀请其好友注册，受邀者可获得1〜100金币奖励，其好友可获得1〜50金币奖励，此时除了受邀者可获得1%%的反馈以外同时邀请者可获得1〜50金币奖励。\n如：A邀请好友B注册，A可获得1〜100金币奖励，B可获得1〜50金币奖励。同时B注册后充值，A可获得1%%的反馈。\nB 邀请好友C注册，B可获得1〜100金币奖励，C可获得1〜50金币奖励。A可获得1〜50金币奖励。\n3、邀请好友注册还可获得查看券：老用户邀请新用户注册成功可获得查看券，新用户注册成功也可获得查看券；\n4、新用户使用查看券之前必须先关注高手，成为高手的粉丝才能使用查看券。\n二、活动说明\n1、用户通过%@提供的分享路径邀请好友注册，受邀者在邀请链接中输入注册手机号并提交成功后即完成一次邀请。\n2、同一IP同一设备只可完成一个注册。\n3、所得奖励金币可用于站内点阅计划与打赏使用，但不能提现\n4、查看券来源于被邀请的新用户注册成功可获取1张查看券，老用户邀请新用户成功也可获得1张查看券， 非邀请首次注册成功的新用户可获得查看券1张。\n5、查看券用于免费查看付费高手计划，仅限当天有效。",APP_NAME];
    
    QXLable *labActivityRules=[[QXLable alloc]initWithFount:12];
    NSMutableAttributedString *attStr=[[NSMutableAttributedString alloc]initWithString:strRules];
    [attStr addAttribute:NSForegroundColorAttributeName value:DEFAULTTEXTBLACKCOLOR range:[strRules rangeOfString:@"一、活动规则"]];
    [attStr addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:15] range:[strRules rangeOfString:@"一、活动规则"]];
    [attStr addAttribute:NSForegroundColorAttributeName value:DEFAULTTEXTBLACKCOLOR range:[strRules rangeOfString:@"二、活动说明"]];
    [attStr addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:15] range:[strRules rangeOfString:@"二、活动说明"]];
    NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
    paraStyle.lineBreakMode = NSLineBreakByCharWrapping;
    paraStyle.lineSpacing = 19; //设置行间距
    [attStr addAttribute:NSParagraphStyleAttributeName value:paraStyle range:NSMakeRange(0, attStr.length)];
    labActivityRules.attributedText=attStr;
    [scrollView addSubview:labActivityRules];
    
    float height=[TGTools getSpaceLabelHeight:strRules withFont:[UIFont systemFontOfSize:12] withWidth:SCREEN_WIDTH-40 andLineSpacing:19];
    
//    CGSize size=[TGTools boundingRectWithString:strRules withSize:CGSizeMake(SCREEN_WIDTH-40, CGFLOAT_MAX) anfont:12];
    [labActivityRules mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(labTitle);
        make.top.equalTo(bgImage.mas_bottom);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-40, height+30));
    }];
    scrollView.contentSize=CGSizeMake(0, height+38+bgImage.image.size.height+150);
    
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
